package cn.yanxiaohui.service.web.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * 1/2/3/4组成多少互不相同且无重复数字的三位数字
 */
public class RandomDemo {
    public static void main(String[] args){
        String string = new MaRenDemo().getString(12, 13);
        System.out.println(string);
    }




    /**
     * 3层循环
     */
    private static void way1() {
        int[] numArr = new int[]{1,2,3,4};
        // 百位、十位、个位
        int a,b,c = 0;
        List<Integer> list = new ArrayList<Integer>(0);
        for (int i = 0; i< numArr.length ; i++) {
            a = numArr[i];
            for (int j = 0; j< numArr.length ; j++){
                b = numArr[j];
                if(a == b){
                    continue;
                }
                for (int k = 0; k< numArr.length ; k++){
                    c = numArr[k];
                    if(a == c || b == c){
                        continue;
                    }
                    int num = a * 100 + b * 10 + c;
                    if(!list.contains(num)){
                        System.out.println(num);
                        list.add(num);
                    }
                }
            }
        }
    }
}
